<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
    <title><%= title %> - <%=website.webname() %></title>
    <link href='/stylesheets/bootstrap.css' rel="stylesheet" type="text/css" />
    <link href='/stylesheets/right.css' rel="stylesheet" type="text/css" />

    <style>
    .navbar-default {
        background-color: #2E3842;
    }
    .navbar-default .navbar-brand {
        color: #FFF;
    }
    .navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus {
        color: #FFF;
        background-color: transparent;
    }
    .navbar-default .navbar-nav > li > a {
        color: #FFF;
    }
    .navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
        color: rgba(255, 255, 255, .5);
    }
    .logo {
        width: 40px;
        height: 40px;
        margin-top: -10px;
    }
    .logo-text {
        margin-top: -27px;
        margin-left: 50px;
        color: #e9e9e9;
    }
    html,body {
        height: 100%;
    }
    .linear {
        background: linear-gradient(#4A6280,#4E3647);
        background:#4A6280;
        background:-moz-linear-gradient(-180deg,#4A6280 0,#4E3647 100%);
        background:-webkit-gradient(linear,left top,right bottom,color-stop(0,#4A6280),color-stop(100%,#4E3647));
        background:-webkit-linear-gradient(-180deg,#4A6280 0,#4E3647 100%);
        background:-o-linear-gradient(-180deg,#4A6280 0,#4E3647 100%);
        background:-ms-linear-gradient(-180deg,#4A6280 0,#4E3647 100%);
        background:linear-gradient(-180deg,#4A6280 0,#4E3647 100%);
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A6280, endColorstr=#4E3647, GradientType=1)
    }
    .platform-logo
    {
        width: 16px;
        height: 16px;
    }
    .platform-name
    {
        color: #515151;
        margin-top: 4px;
    }

</style>
</head>
<body>
<div class="container">
    <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand logo-row" href="#">
                    <img class="logo" src="<%=website.logo()%>" alt="logo"/>
                    <p class="logo-text"><%=website.webname() %></p>
                </a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <!--向右对齐-->
                <% if (user) { %>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="/">首页</a></li>

                    <% if (user.root || (user.role && ((user.role.permissions.managerI || user.role.permissions.packageI) && (user.role.permissions.managerA || user.role.permissions.packageA)))) { %>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            打包
                            <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="/package?platform=ios">
                                    <img class="platform-logo" src="/images/ios.png" alt="">
                                    <span class="platform-name">&nbsp;&nbsp;iOS 打包</span>
                                </a>
                            </li>
                            <li><a href="/package?platform=android">
                                    <img class="platform-logo" src="/images/android.png" alt="">
                                    <span class="platform-name">&nbsp;&nbsp;Android 打包</span>
                                </a>
                            </li>
                        </ul>
                    </li>
                    <% } else if (user.root || (user.role && (user.role.permissions.managerI || user.role.permissions.packageI))) {%>
                    <li>
                        <a href="/package?platform=ios">打包</a>
                    </li>
                    <% } else if (user.root || (user.role && (user.role.permissions.managerA || user.role.permissions.packageA))) {%>
                    <li>
                        <a href="/package?platform=android">打包</a>
                    </li>
                    <% } %>

                    <% if (user.root || (user.role && (user.role.permissions.managerI && user.role.permissions.managerA))) { %>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            模块
                            <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="/component?platform=ios">
                                    <img class="platform-logo" src="/images/ios.png" alt="">
                                    <span class="platform-name">&nbsp;&nbsp;iOS 模块</span>
                                </a>
                            </li>
                            <li><a href="/component?platform=android">
                                    <img class="platform-logo" src="/images/android.png" alt="">
                                    <span class="platform-name">&nbsp;&nbsp;Android 模块</span>
                                </a>
                            </li>
                        </ul>
                    </li>
                    <% } else if (user.root || (user.role && user.role.permissions.managerI)) {%>
                    <li>
                        <a href="/component?platform=ios">模块</a>
                    </li>
                    <% } else if (user.root || (user.role && user.role.permissions.managerA)) {%>
                    <li>
                        <a href="/component?platform=android">模块</a>
                    </li>
                    <% } %>

                    <li><a href="/guanjia">包管理器</a></li>
                    <li><a href="/help">帮助</a></li>

                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            管理中心
                            <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            <% if (user.root) { %>
                            <li><a href="/admin/user">用户管理</a></li>
                            <li><a href="/admin/role">角色管理</a></li>
                            <li><a href="/admin/guanjia">包管理器</a></li>
                            <li><a href="/admin/setting">系统设置</a></li>
                            <li class="divider"></li>
                            <li><a href="/admin/robot">钉钉通知</a></li>
                            <li><a href="/admin/delegater">代理机器</a></li>
                            <li><a href="/admin/gituser">仓库用户</a></li>
                            <li class="divider"></li>
                            <% } %>
                            <% if (user.root || (user.role && user.role.permissions.article)) { %>
                            <li><a href="/ueditor">文档管理</a></li>
                            <% } %>
                            <% if (user.root || (user.role && user.role.permissions.article  && (user.role.permissions.managerA || user.role.permissions.managerI))) { %>
                            <li class="divider"></li>
                            <% } %>
                            <% if (user.root || (user.role && (user.role.permissions.managerA || user.role.permissions.managerI))) { %>
                            <li><a href="/app/">应用管理</a></li>
                            <% if (user.root) { %>
                            <li class="divider"></li>
                            <li><a href="/admin/repo">Repo管理</a></li>
                            <% } %>
                            <% } %>



                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <%= user.nickname %>
                            <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="/user/center/<%= user.username%>">个人中心</a></li>
                            <li><a href="/user/logout">退出登录</a></li>
                        </ul>
                    </li>
                </ul>
                <% } else { %>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="/">首页</a></li>
                    <li><a href="/guanjia">包管理器</a></li>
                    <li><a href="/help">帮助</a></li>
                    <!--<li><a href="/user/apply">申请账号</a></li>-->
                    <li><a href="/user/login">登录</a></li>
                </ul>
                <% } %>
            </div>
        </div>
    </nav>
</div>
<div id="tip-view-s" class="alert alert-success navbar-fixed-top top-alert" style="display: none">
    <p id="tip-text-s"></p>
</div>
<div id="tip-view-e" class="alert alert-warning navbar-fixed-top top-alert" style="display: none">
    <p id="tip-text-e"></p>
</div>

<% if (success) { %>
<div id="alert-view" class="alert alert-success navbar-fixed-top top-alert">
    &nbsp;&nbsp;&nbsp;&nbsp;<%= success %>
</div>
<% } %>
<% if (error) { %>
<div id="alert-view" class="alert alert-warning navbar-fixed-top top-alert">
    &nbsp;&nbsp;&nbsp;&nbsp;<%= error %>
</div>
<% } %>

<script src="/javascripts/jquery.min.js"></script>
<script src="/javascripts/bootstrap.min.js"></script>
<div id="container" class="container" style="margin-top: 50px">
    <%- body %>

    <footer>
        <div style="text-align: center;margin-top: 50px">
            <% if (!website.ipack()){ %>
            <p style="color: rgba(0, 0, 0, 0.8);font-size: 12px"><a style="color: rgba(0, 0, 0, 0.8)" href="<%= baseUrl %>" target="_blank"><%= website.webname() %></a></p>
            <% } else { %>
            <p style="color: rgba(255, 255, 255, 0.8);font-size: 12px">Powered by <a href="https://ipack.pub" target="_blank">iPack</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="color: rgba(255, 255, 255, 0.8)" href="<%= baseUrl %>" target="_blank"><%= website.webname() %></a></p>
            <% } %>
        </div>
    </footer>
</div>
</body>

<script language="JavaScript">
    window.onload = function () {
        setTimeout(hide, 1000);
    }
    function hide() {
        var alertView = window.document.getElementById('alert-view');
        if (alertView) {
            alertView.style.display = 'none';
        }
    }
    function showSuccess(text) {
        var alertView = window.document.getElementById('tip-view-s');
        if (alertView) {
            alertView.style.display = 'inline';
            $("#tip-text-s").text('    ' + text);
            setTimeout(function () {
                alertView.style.display = 'none';
            },1000);
        }

    }
    function showError(text) {
        var alertView = window.document.getElementById('tip-view-e');
        if (alertView) {
            alertView.style.display = 'inline';
            $("#tip-text-e").text('    ' +text);
            setTimeout(function () {
                alertView.style.display = 'none';
            },1000);
        }

    }

    $('#none-permission-pa,#none-permission-pi,#none-permission-mi,#none-permission-mi').click(function () {
        showError('对不起，您无权操作');
    })
</script>
</html>